### this is code to generate ration estimates for three species under 4 scenarios:
# 1. using livingston model with 3 degc
# 2. using livingston model with annual temps from index
# 3. using livingston model with annual temps for biomass weighted temperature
# 4. using wisconsin model with annual temps for biomass weight temperature
setwd("/Users/kkari/Documents/science/SVN/MSM/svn (trunk)/")
source("KIRM2/MSMration.R")
setwd("/Users/kkari/Documents/science/SVN/MSM/svn (trunk)/")
graphics.off()
dat<-read.csv("tmsm.dat")
nyrs<-32
styr<-1979
years<-styr:(styr+nyrs-1)


#######################################
# low hanging fruit - variable temps
#######################################
#1 extract temp effect:
dat<-read.csv("oldration.csv",sep = ",",comment.char="#")
starts<-c(1,nyrs+2,nyrs*2+2)
ration<-list(pollock=dat[starts[1]:(nyrs+starts[1]-1),],pcod=dat[starts[2]:(nyrs+starts[2]-1),]
	,arrowtooth=dat[starts[3]:(nyrs+starts[3]-1),])
rownames(ration$pollock)<-years;rownames(ration$pcod)<-years;rownames(ration$arrowtooth)<-years
ration$pollock<-data.frame(ration$pollock)
ration$pcod<-data.frame(ration$pcod)
ration$arrowtooth<-data.frame(ration$arrowtooth)

oldration<-rbind(pollock=as.numeric(ration$pollock[1,]),pcod=as.numeric(ration$pcod[1,]),arrowtooth=as.numeric(ration$arrowtooth[1,]))
livingston<-0.0134*exp(0.115*3)
oldstomprop<-oldration/livingston
## USE T index
T.use<-Temp.data$EBS_bottomT
ration.index.plk<-t(oldstomprop[1,]%*%t((0.0134*exp(0.115*T.use))))
ration.index.pcod<-t(oldstomprop[2,]%*%t((0.0134*exp(0.115*T.use))))
ration.index.arrowtooth<-t(oldstomprop[3,]%*%t((0.0134*exp(0.115*T.use))))
plot(oldration[1,],type="b",ylim=c(0,15),pch=16,xlab="Age",ylab="Annual ration")
for(i in 1:length(T.use)){points(ration.index.plk[i,],type="l",col="gray",lwd=.5)}
points(oldration[2,],type="b",ylim=c(0,13),pch=16,col="red")
for(i in 1:length(T.use)){points(ration.index.pcod[i,],type="l",col=colors()[92],lwd=.5)}
points(oldration[3,],type="b",ylim=c(0,13),pch=16,col="blue")
for(i in 1:length(T.use)){points(ration.index.arrowtooth[i,],type="l",col=colors()[617],lwd=.5)}
points(oldration[3,],type="b",ylim=c(0,13),pch=16,col="blue")
points(oldration[1,],type="b",ylim=c(0,13),pch=16)
points(oldration[2,],type="b",ylim=c(0,13),pch=16,col="red")

#########################################################
## Remove zeros and output to .dat file
#########################################################
T.use<-rep(0,32)
outfile<-"rationTindex.dat"
cat("# ration using T index: pollock ",file=outfile,append=FALSE,sep="\n")
for(i in 1:length(T.use)){cat(na.omit(ration.index.plk[i,]),file=outfile,append=TRUE,sep=" ");cat("",file=outfile,append=TRUE,sep="\n")}
cat("# pcod ",file=outfile,append=TRUE,sep="\n")
for(i in 1:length(T.use)){cat(na.omit(ration.index.pcod[i,]),file=outfile,append=TRUE,sep=" ");cat("",file=outfile,append=TRUE,sep="\n")}
cat("# arrowtooth ",file=outfile,append=TRUE,sep="\n")
for(i in 1:length(T.use)){cat(na.omit(ration.index.arrowtooth[i,]),file=outfile,append=TRUE,sep=" ");cat("",file=outfile,append=TRUE,sep="\n")}


T.use<-Temp.data$pollock.T;ration.biomassT.plk<-t(oldstomprop[1,]%*%t((0.0134*exp(0.115*T.use))))
T.use<-Temp.data$pcod.T;ration.biomassT.pcod<-t(oldstomprop[2,]%*%t((0.0134*exp(0.115*T.use))))
T.use<-Temp.data$arrowtooth.T;ration.biomassT.arrowtooth<-t(oldstomprop[3,]%*%t((0.0134*exp(0.115*T.use))))
plot(oldration[1,],type="b",ylim=c(0,15),pch=16,xlab="Age",ylab="Annual ration")
for(i in 1:length(T.use)){points(ration.biomassT.plk[i,],type="l",col="gray",lwd=.5)}
points(oldration[2,],type="b",ylim=c(0,13),pch=16,col="red")
for(i in 1:length(T.use)){points(ration.biomassT.pcod[i,],type="l",col=colors()[92],lwd=.5)}
points(oldration[3,],type="b",ylim=c(0,13),pch=16,col="blue")
for(i in 1:length(T.use)){points(ration.biomassT.arrowtooth[i,],type="l",col=colors()[617],lwd=.5)}
points(oldration[3,],type="b",ylim=c(0,13),pch=16,col="blue")
points(oldration[1,],type="b",ylim=c(0,13),pch=16)
points(oldration[2,],type="b",ylim=c(0,13),pch=16,col="red")

#########################################################
## Remove zeros and output to .dat file
#########################################################
T.use<-rep(0,32)
outfile<-"rationTbiomass.dat"
cat("# ration using T index: pollock ",file=outfile,append=FALSE,sep="\n")
for(i in 1:length(T.use)){cat(na.omit(ration.biomassT.plk[i,]),file=outfile,append=TRUE,sep=" ");cat("",file=outfile,append=TRUE,sep="\n")}
cat("# pcod ",file=outfile,append=TRUE,sep="\n")
for(i in 1:length(T.use)){cat(na.omit(ration.biomassT.pcod[i,]),file=outfile,append=TRUE,sep=" ");cat("",file=outfile,append=TRUE,sep="\n")}
cat("# arrowtooth ",file=outfile,append=TRUE,sep="\n")
for(i in 1:length(T.use)){cat(na.omit(ration.biomassT.arrowtooth[i,]),file=outfile,append=TRUE,sep=" ");cat("",file=outfile,append=TRUE,sep="\n")}




#######################################
# estimate Weight at Age
#######################################
## again using length weight data from database
dat<-LWdata2[which(LWdata2$AGE>0),]

########### Pollock
dat.use<-dat[dat$GOAPOLL_PRED=="WALLEYE POLLOCK",]
ages<-sort(unique(dat.use$AGE))
m.p<-polr(factor(age)~weight,data=list(age=dat.use$AGE,weight=dat.use$WEIGHT),method="logistic")  # ordered probit model - proportional odds logistic regression
t.m.p<-data.frame(m.p$zeta)
graphics.off()
par(mfrow=c(3,1))
plot(dat.use$WEIGHT,dat.use$AGE, pch=16,cex=.8, main="pollock")
points(t.m.p[,1]/coef(m.p),ages[-1],type="b",pch=16,col="red",lwd=1,main="pollock")
WatA.plk<-cbind(t.m.p[,1]/coef(m.p),ages[-1])
S.1$pred.age<-predict(m.p,newdata=data.frame(weight=S.1$Wt))
ages<-sort(unique(dat.use$AGE))
m.p<-polr(factor(age)~length,data=list(age=dat.use$AGE,length=dat.use$LENGTH/10),method="logistic")  # ordered probit model - proportional odds logistic regression
t.m.p<-data.frame(m.p$zeta)
LatA.plk<-cbind(t.m.p[,1]/((coef(m.p))),ages[-1])
text(as.numeric(names(LatA.plk)),LatA.plk,names(LatA.plk))
pollock$pred.age<-predict(m.p,newdata=data.frame(length=pollock$Length))
ages.pollock<-ages
### PICK UP HERE _
# get LW to work, then generate rations for set T (3) and variable T(Tbiomass)
########### pcod


#pcod_LW<-pcod_WA[is.na(pcod_WA$WEIGHT)==FALSE,]
#ages<-sort(unique(pcod_LW$AGE))
dat.use<-dat[dat$GOAPOLL_PRED=="PACIFIC COD",]
ages<-sort(unique(dat.use$AGE))
m.pcod<-polr(factor(age)~weight,data=list(age=pcod_LW$AGE,weight=pcod_LW$WEIGHT),method="logistic")  # ordered probit model - proportional odds logistic regression
t.m.pcod<-data.frame(summary(m.pcod)[1])
plot(pcod_LW$WEIGHT,pcod_LW$AGE, pch=16,cex=.8,main="P Cod")
points(t.m.pcod[-1,1]/(coef(m.pcod)),ages[-1],type="b",pch=16,col="red",lwd=1,main="pollock")
WatA.pcod<-cbind(t.m.pcod[-1,1]/(coef(m.pcod)),ages[-1])
S.2$pred.age<-predict(m.pcod,newdata=data.frame(weight=S.2$Wt))
ages.pcod<-ages
ages<-sort(unique(pcod_LW$AGE))
m.pcod<-polr(factor(age)~length,data=list(age=pcod_LW$AGE,length=pcod_LW$LENGTH/10),method="logistic")  # ordered probit model - proportional odds logistic regression
t.m.pcod<-data.frame(m.pcod$zeta)
LatA.pcod<-cbind(t.m.pcod[,1]/(coef(m.pcod)),ages[-1])
#text(as.numeric(names(LatA.pcod)),LatA.pcod,names(LatA.pcod))
pcod$pred.age<-predict(m.pcod,newdata=data.frame(length=pcod$Length))

########### arrowtooth
dat.use<-dat[dat$GOAPOLL_PRED=="ARROWTOOTH FLOUNDR",]
ages<-sort(unique(dat.use$AGE))
m.arrowtooth<-polr(factor(age)~weight,data=list(age=dat.use$AGE,weight=dat.use$WEIGHT),method="logistic")  # ordered probit model - proportional odds logistic regression
t.m.arrowtooth<-data.frame(m.arrowtooth$zeta)
plot(dat.use$WEIGHT,dat.use$AGE, pch=16,cex=.8, main="arrowtooth")
points(t.m.arrowtooth[,1]/coef(m.arrowtooth),ages[-1],type="b",pch=16,col="red",lwd=1,main="arrowtooth")
WatA.arrowtooth<-cbind(t.m.arrowtooth[,1]/coef(m.arrowtooth),ages[-1])
S.3$pred.age<-predict(m.arrowtooth,newdata=data.frame(weight=S.3$Wt))
ages.arrowtooth<-ages
m.patf<-polr(factor(age)~length,data=list(age=dat.use$AGE,length=dat.use$LENGTH/10),method="logistic")  # ordered probit model - proportional odds logistic regression
t.m.patf<-data.frame(m.patf$zeta)
LatA.arrowtooth<-cbind(t.m.patf[,1]/(coef(m.patf)),ages[-1])
#text(as.numeric(names(LatA.arrowtooth)),LatA.pcod,names(LatA.arrowtooth))
arrowtooth$pred.age<-predict(m.patf,newdata=data.frame(length=arrowtooth$Length))

dev.new()
plot(WatA.plk,type="b",main="",pch=16,xlab="Weight",ylab="Age")
points(WatA.pcod,type="b",main="pollock",col="red",pch=16)
points(WatA.arrowtooth,type="b",main="pollock",col="blue",pch=16)
legend(200,28,c("pollock","pcod","arrowtooth"),col=c("black","red","blue"),lwd=2,pch=16,lty=1,box.lwd=0)

plot(LatA.plk,type="b",main="",pch=16,xlab="Weight",ylab="Age")
points(LatA.pcod,type="b",main="pollock",col="red",pch=16)
points(LatA.arrowtooth,type="b",main="pollock",col="blue",pch=16)
legend(200,28,c("pollock","pcod","arrowtooth"),col=c("black","red","blue"),lwd=2,pch=16,lty=1,box.lwd=0)

## plot rations to see how they compare

plot(as.numeric(ration$pollock[1,]),type="b",pch=16,ylim=c(0,13),ylab="annual ration",xlab="Age")
points(as.numeric(ration$pcod[1,]),type="b",col="red",pch=16)
points(as.numeric(ration$arrowtooth[1,]),type="b",col="blue",pch=16)



dat<-pollock[is.na(pollock$pred.age2)==FALSE,];stomWA.plk<-tapply(dat$TotWt,dat$pred.age,mean.na)/100
#stomWA.plk<-stomWA.plk*t.m.p[match(na.omit(as.numeric(names(stomWA.plk)))+1,ages.pollock),1]
dat<-pcod[is.na(pcod$pred.age)==FALSE,];stomWA.pcod<-tapply(dat$TotWt,dat$pred.age,mean.na)/100
#stomWA.pcod<-stomWA.pcod*t.m.p[match(na.omit(as.numeric(names(stomWA.pcod)))+1,ages.pcod),1]
dat<-arrowtooth[is.na(arrowtooth$pred.age2)==FALSE,];stomWA.arrowtooth<-tapply(dat$TotWt,dat$pred.age2,mean.na)/100
#stomWA.arrowtooth<-stomWA.arrowtooth*t.m.p[match(na.omit(as.numeric(names(stomWA.arrowtooth)))+1,ages.arrowtooth),1]

plot(oldstomprop[1,],type="b",pch=16,ylim=c(0,.4),ylab="annual ration",xlab="Age")
points(oldstomprop[2,],type="b",col="red",pch=16)
points(oldstomprop[3,],type="b",col="blue",pch=16)
points(as.numeric(names(stomWA.plk)),stomWA.plk,type="l")
points(as.numeric(names(stomWA.pcod)),stomWA.pcod,type="l",col="red")
points(as.numeric(names(stomWA.arrowtooth)),stomWA.arrowtooth,type="l",col="blue")

#S.1$age<-predict(m.p,newdata=data.frame(weight=S.1$Wt*10))






#######################################
# Now use sizeAtage to make new rations
#######################################
#####
sizeAtage<-list(
	pollock=tapply(pollock$Length,pollock$pred.age,mean.na),
	pcod=tapply(pcod$Length,pcod$pred.age,mean.na),
	arrowtooth=tapply(arrowtooth$Length,arrowtooth$pred.age,mean.na))
i<-3
	dat<-sizeAtage[[i]]
	upp<-which(is.na(dat))+1;dwnn<-which(is.na(dat))-1
	for (j in 1:(length(upp)-1)){
		sizeAtage[[i]][which(is.na(dat))][j]<-mean(dat[upp[j]],dat[dwnn[j]])
	}
	sizeAtage[[i]][21]<-sizeAtage[[i]][20]

for(i in 1:3){
	sizeAtage[[i]]<-rbind(Length=sizeAtage[[i]],Wt=sp.dat$LW.a[i]*sizeAtage[[i]]^sp.dat$LW.b[i])
}



Tuse<-3
nages<-rep(0,3);for (sp in 1:3){nages[sp]<-length(na.omit(oldration[sp,]))}
pcod.new<-model.parms[4,]
newrat<-matrix(0,nyrs,nages[sp])
#############  POLLOCK  ##################
sp<-1
#Tuse<-mean(Temp.data$pollock.T)
newration<-matrix(0,nyrs,nages[sp])
pn<-c(1,4,5)
par(mfrow=c(3,1))
plot(oldration[sp,],type="l",ylim=c(0,25),col=col5,lwd=2)
for(y in 1:nyrs){
	ft<-bioenergetics(model.parms[pn[sp],],12,Tuse,1,3000,3000)$fTc
	tt<-bioenergetics(model.parms[pn[sp],],sizeAtage[[sp]][1,1:nages[sp]],Tuse,.3,3000,3000)
	newration[y,]<-tt$C*sizeAtage[[sp]][2,1:nages[sp]]	
}
lines(newration[1,],lwd=2,col=col2)
outfile<-"newration3deg.dat"
cat("# new ration using 3 deg: pollock ",file=outfile,append=FALSE,sep="\n")
for(i in 1:length(newration[,1])){cat(newration[i,],file=outfile,append=TRUE,sep=" ");cat("",file=outfile,append=TRUE,sep="\n")}
#############  PCOD  ##################
#Tuse<-mean(Temp.data$pcod.T)
sp<-2
newration<-matrix(0,nyrs,nages[sp])
plot(oldration[sp,],type="l",ylim=c(0,25),col=col5,lwd=2)
for(y in 1:nyrs){
	ft<-bioenergetics(model.parms[pn[sp],],12,3,1,3000,3000)$fTc
	tt<-bioenergetics(model.parms[pn[sp],],sizeAtage[[sp]][2,1:nages[sp]],Tuse,1,3000,3000)
	newration[y,]<-tt$C*sizeAtage[[sp]][2,1:nages[sp]]	
}
lines(newration[1,],lwd=2,col=col2)
cat("# pcod ",file=outfile,append=TRUE,sep="\n")
for(i in 1:length(newration[,1])){cat(newration[i,],file=outfile,append=TRUE,sep=" ");cat("",file=outfile,append=TRUE,sep="\n")}
#############  ARROWTOOTH  ##################
sp<-3
#Tuse<-mean(Temp.data$arrowtooth.T)
newration<-matrix(0,nyrs,nages[sp])
plot(oldration[sp,],type="l",ylim=c(0,25),col=col5,lwd=2)
for(y in 1:nyrs){
	ft<-bioenergetics(model.parms[pn[sp],],12,3,1,3000,3000)$fTc
	tt<-bioenergetics(model.parms[pn[sp],],sizeAtage[[sp]][2,1:nages[sp]],Tuse,1,3000,3000)
	newration[y,]<-tt$C*sizeAtage[[sp]][2,1:nages[sp]]
}
lines(newration[1,],lwd=2,col=col2)
cat("# arrowtooth ",file=outfile,append=TRUE,sep="\n")
for(i in 1:length(newration[,1])){cat(newration[i,],file=outfile,append=TRUE,sep=" ");cat("",file=outfile,append=TRUE,sep="\n")}

Temp.data$pollock.T[is.na(Temp.data$pollock.T)]<-mean.na(Temp.data$pollock.T)
Temp.data$pcod.T[is.na(Temp.data$pcod.T)]<-mean.na(Temp.data$pcod.T)
Temp.data$arrowtooth.T[is.na(Temp.data$arrowtooth.T)]<-mean.na(Temp.data$arrowtooth.T)
Temp.data$pcod.T[(Temp.data$pcod.T)==0]<-mean.na(Temp.data$pcod.T)
Temp.data$arrowtooth.T[(Temp.data$arrowtooth.T)==0]<-mean.na(Temp.data$arrowtooth.T)

#### variable temp (index)
Tuse<-Temp.data$EBS_bottomT
nages<-rep(0,3);for (sp in 1:3){nages[sp]<-length(na.omit(oldration[sp,]))}
pcod.new<-model.parms[4,]
newrat<-matrix(0,nyrs,nages[sp])
#############  POLLOCK  ##################
sp<-1
#Tuse<-mean(Temp.data$pollock.T)
newration<-matrix(0,nyrs,nages[sp])
pn<-c(1,4,5)
par(mfrow=c(3,1))
plot(oldration[sp,],type="l",ylim=c(0,25),col=col5,lwd=2)
for(y in 1:nyrs){
	ft<-bioenergetics(model.parms[pn[sp],],12,Tuse,1,3000,3000)$fTc
	tt<-bioenergetics(model.parms[pn[sp],],sizeAtage[[sp]][1,1:nages[sp]],Tuse[y],.3,3000,3000)
	newration[y,]<-tt$C*sizeAtage[[sp]][2,1:nages[sp]]	
}
lines(newration[1,],lwd=2,col=col2)
outfile<-"newrationTindex.dat"
cat("# new ration using index : pollock ",file=outfile,append=FALSE,sep="\n")
for(i in 1:length(newration[,1])){cat(newration[i,],file=outfile,append=TRUE,sep=" ");cat("",file=outfile,append=TRUE,sep="\n")}
#############  PCOD  ##################
#Tuse<-mean(Temp.data$pcod.T)
sp<-2
newration<-matrix(0,nyrs,nages[sp])
plot(oldration[sp,],type="l",ylim=c(0,25),col=col5,lwd=2)
for(y in 1:nyrs){
	ft<-bioenergetics(model.parms[pn[sp],],12,3,1,3000,3000)$fTc
	tt<-bioenergetics(model.parms[pn[sp],],sizeAtage[[sp]][2,1:nages[sp]],Tuse[y],1,3000,3000)
	newration[y,]<-tt$C*sizeAtage[[sp]][2,1:nages[sp]]	
}
lines(newration[1,],lwd=2,col=col2)
cat("# pcod ",file=outfile,append=TRUE,sep="\n")
for(i in 1:length(newration[,1])){cat(newration[i,],file=outfile,append=TRUE,sep=" ");cat("",file=outfile,append=TRUE,sep="\n")}
#############  ARROWTOOTH  ##################
sp<-3
#Tuse<-mean(Temp.data$arrowtooth.T)
newration<-matrix(0,nyrs,nages[sp])
plot(oldration[sp,],type="l",ylim=c(0,25),col=col5,lwd=2)
for(y in 1:nyrs){
	ft<-bioenergetics(model.parms[pn[sp],],12,3,1,3000,3000)$fTc
	tt<-bioenergetics(model.parms[pn[sp],],sizeAtage[[sp]][2,1:nages[sp]],Tuse[y],1,3000,3000)
	newration[y,]<-tt$C*sizeAtage[[sp]][2,1:nages[sp]]*3
}
lines(newration[1,],lwd=2,col=col2)
cat("# arrowtooth ",file=outfile,append=TRUE,sep="\n")
for(i in 1:length(newration[,1])){cat(newration[i,],file=outfile,append=TRUE,sep=" ");cat("",file=outfile,append=TRUE,sep="\n")}


#### variable temp (biomass weighted)
#Tuse<-Temp.data$EBS_bottomT
nages<-rep(0,3);for (sp in 1:3){nages[sp]<-length(na.omit(oldration[sp,]))}
pcod.new<-model.parms[4,]
newrat<-matrix(0,nyrs,nages[sp])
#############  POLLOCK  ##################
sp<-1
Tuse<-(Temp.data$pollock.T)
newration<-matrix(0,nyrs,nages[sp])
pn<-c(1,4,5)
par(mfrow=c(3,1))
plot(oldration[sp,],type="l",ylim=c(0,25),col=col5,lwd=2)
for(y in 1:nyrs){
	ft<-bioenergetics(model.parms[pn[sp],],12,Tuse,1,3000,3000)$fTc
	tt<-bioenergetics(model.parms[pn[sp],],sizeAtage[[sp]][1,1:nages[sp]],Tuse[y],.3,3000,3000)
	newration[y,]<-tt$C*sizeAtage[[sp]][2,1:nages[sp]]	
}
lines(newration[1,],lwd=2,col=col2)
outfile<-"newrationTbiomass.dat"
cat("# new ration using biomass weighted temperature : pollock ",file=outfile,append=FALSE,sep="\n")
for(i in 1:length(newration[,1])){cat(newration[i,],file=outfile,append=TRUE,sep=" ");cat("",file=outfile,append=TRUE,sep="\n")}
#############  PCOD  ##################
Tuse<-(Temp.data$pcod.T)
sp<-2
newration<-matrix(0,nyrs,nages[sp])
plot(oldration[sp,],type="l",ylim=c(0,25),col=col5,lwd=2)
for(y in 1:nyrs){
	ft<-bioenergetics(model.parms[pn[sp],],12,3,1,3000,3000)$fTc
	tt<-bioenergetics(model.parms[pn[sp],],sizeAtage[[sp]][2,1:nages[sp]],Tuse[y],1,3000,3000)
	newration[y,]<-tt$C*sizeAtage[[sp]][2,1:nages[sp]]	
}
lines(newration[1,],lwd=2,col=col2)
cat("# pcod ",file=outfile,append=TRUE,sep="\n")
for(i in 1:length(newration[,1])){cat(newration[i,],file=outfile,append=TRUE,sep=" ");cat("",file=outfile,append=TRUE,sep="\n")}
#############  ARROWTOOTH  ##################
sp<-3
Tuse<-(Temp.data$arrowtooth.T)
newration<-matrix(0,nyrs,nages[sp])
plot(oldration[sp,],type="l",ylim=c(0,25),col=col5,lwd=2)
for(y in 1:nyrs){
	ft<-bioenergetics(model.parms[pn[sp],],12,3,1,3000,3000)$fTc
	tt<-bioenergetics(model.parms[pn[sp],],sizeAtage[[sp]][2,1:nages[sp]],Tuse[y],1,3000,3000)
	newration[y,]<-tt$C*sizeAtage[[sp]][2,1:nages[sp]]
}
lines(newration[1,],lwd=2,col=col2)
cat("# arrowtooth ",file=outfile,append=TRUE,sep="\n")
for(i in 1:length(newration[,1])){cat(newration[i,],file=outfile,append=TRUE,sep=" ");cat("",file=outfile,append=TRUE,sep="\n")}




###############

